import 'package:backend.core/core/domain/entities/admin.dart';
import 'package:backend.core/core/domain/entities/end_user.dart';
import 'package:backend.core/core/domain/entities/user.dart';
import 'package:backend.core/core/infrastructure/dtos/api/api_admin_dto.dart';
import 'package:backend.core/core/infrastructure/dtos/api/api_end_user_dto.dart';
import 'package:backend.core/core/infrastructure/dtos/api/api_user_dto.dart';

class ApiUserDtoFactory {
  const ApiUserDtoFactory._internal();

  static const _instance = ApiUserDtoFactory._internal();

  factory ApiUserDtoFactory() {
    return _instance;
  }

  ApiUserDto fromEntity(User user) {
    if (user is Admin) {
      return ApiAdminDto.fromEntity(user);
    }

    if (user is EndUser) {
      return ApiEndUserDto.fromEntity(user);
    }

    throw UnimplementedError();
  }
}
